<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.8/vue-router.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>

</head>

<body>
    <div id='app'>

        <router-view></router-view>
        <ul>
            <li v-for="(item,index) in res" :key=index>
                <router-link :to="{path:'/comment',query:{courseId:item.courseId}}">{{item.courseTitle}}</router-link>
                {{item.courseId}}

            </li>
        </ul>
    </div>
    <template id="demo1">
        <div>

        </div>
    </template>
    <template id="demo2">
        <div>
            <router-link to='/'>返回</router-link>
            {{courseTitle}}
        </div>
    </template>
    <script>
        let login1 = {
            template: "#demo1"
        }
        let login2 = {
            template: "#demo2",
            data() {
                return {
                    courseTitle: ''
                }
            },
            created() {
                console.log(this.$route.query.courseId);
                let courseId = this.$route.query.courseId
                // debugger
                axios.get(`http://59.111.104.104:8086/pc/course/detail/${courseId}`).then((res) => {
                    console.log(res);
                    this.courseTitle = res.data.data.courseTitle
                })
            }
        }
    </script>
    <script>
        let router = new VueRouter({
            routes: [
                {
                    path: "/",
                    component: login1

                },
                {
                    path: "/comment",
                    component: login2

                }
            ]
        })
        const vm = new Vue({
            el: '#app',
            data: {
                res: []
            },
            router,
            created() {
                let parms = new URLSearchParams
                parms.append("type", "free")
                parms.append("pageNum", 1)
                parms.append("pageSize", 10)
                axios.post(`http://59.111.104.104:8086/weChat/applet/course/list/type`, parms).then((res) => {
                    console.log(res);
                    this.res = res.data.rows
                })
            }
        })
    </script>
</body>

</html>